home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / instcopy < prev    next >
Encoding:
Text File  |  2001-01-01  |  1022 b   |  45 lines

  1. #!/bin/sh
  2. # $Id: instcopy,v 1.1 2000/03/09 08:40:43 lpd Exp $
  3. #
  4. # Implement a uniform 'install' syntax independent of which of the two
  5. # "standard" install programs is installed.  Based on ideas in, but not
  6. # copied from, the GNU fileutils install-sh script.  Usage:
  7. #    instcopy -c [-m <mode>] <srcfile> (<dstdir>|<dstfile>)
  8.  
  9. doit=""
  10. # Uncomment the following line for testing
  11. #doit="echo "
  12.  
  13. mode=""
  14.  
  15.     while true; do
  16.     case "$1" in
  17.         -c) ;;
  18.         -m) mode=$2; shift ;;
  19.         *) break ;;
  20.         esac
  21.     shift; done
  22.  
  23. src=$1
  24. dst=$2
  25.  
  26.     if [ $# = 2 -a -f $src ]; then true; else
  27.     echo "Usage: instcopy -c [-m <mode>] <srcfile> (<dstdir>|<dstfile>)"
  28.     exit 1
  29.     fi
  30.  
  31. if [ -d $dst ]; then
  32.     dstdir=`echo $dst | sed -e 's,/$,,'`
  33.     dst="$dstdir"/`basename $src`
  34. else
  35.     dstdir=`echo $dst | sed -e 's,/[^/]*$,,'`
  36. fi
  37. dsttmp=$dstdir/#inst.$$#
  38.  
  39. $doit cp $src $dsttmp &&
  40. $doit trap "rm -f $dsttmp" 0 &&
  41. if [ x"$mode" != x ]; then $doit chmod $mode $dsttmp; else true; fi &&
  42. $doit rm -f $dst &&
  43. $doit mv $dsttmp $dst &&
  44. exit 0
  45.